import { CrudOptions } from "@nestjsx/crud";
import { HandleStatus } from "libs/db/entity/enum/handle-status.enum";
import { SubsidyType } from "libs/db/entity/subsidy-type.entity";
import { LoggerInfo, moduleLoggerInfo } from "../_decorator/logger-info";

export const SubsidyTypeCrudOps: CrudOptions = {
  model: {
    type: SubsidyType
  },
  query: {
    join: {
      subsidy: {
        eager: true,          
        exclude:  ["updatedAt", "deleteAt"],
      },
      village: {
          
        exclude:  ["updatedAt", "deleteAt"],
      },
      "village.town": {
          
        exclude:  ["updatedAt", "deleteAt"],
      },
    },
    exclude:  ["updatedAt", "deleteAt"]
  },
  routes: {
    getManyBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('补助类型查询', HandleStatus.LOG)
        ),
      ],
    },
    getOneBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('单个补助类型查询', HandleStatus.LOG)
        ),
      ],
    },
    createOneBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('新增补助类型', HandleStatus.INFO)
        ),
      ],
      returnShallow: true,
    },
    createManyBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('补助类型上传', HandleStatus.DATA)
        ),
      ],
    },
    replaceOneBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('修改补助类型', HandleStatus.WARN)
        ),
      ],
      allowParamsOverride: true,
      returnShallow: true,
    },
    updateOneBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('修改补助类型', HandleStatus.WARN)
        ),
      ],
      allowParamsOverride: true,
      returnShallow: true,
    },
    deleteOneBase: {
      interceptors: [],
      decorators: [
        LoggerInfo(
          new moduleLoggerInfo ('删除补助类型', HandleStatus.ERROR)
        ),
      ],
      returnDeleted: true,
    },
  },
  dto: {
    create: SubsidyType,
    replace: SubsidyType
  },
  serialize: {
    getMany: SubsidyType,
    get: SubsidyType,
    create: SubsidyType,
    createMany: SubsidyType,
    update: SubsidyType,
    replace: SubsidyType,
    delete: SubsidyType,
  }
}